<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>学生信息查看</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">
  <link rel="stylesheet" href="/css/style.css?v=1.0">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar navbar-expand-lg navbar-dark bg-gradient">
  <div class="container">
    <a class="navbar-brand" href="#">
      <i class="fas fa-graduation-cap me-2"></i>学生信息管理系统
    </a>
    <div class="d-flex">
      <!-- 在 index.html 或其他模板中 -->
      <a th:href="@{/logout}" class="btn btn-outline-light ms-2" th:attr="onclick='event.preventDefault(); document.getElementById(\'logout-form\').submit();'">退出登录</a>
      <form id="logout-form" action="#" th:action="@{/logout}" method="post" th:csrfinput></form>
    </div>
  </div>
</nav>

<div class="container my-5">
  <!-- 头部区域 -->
  <div class="header-card p-4 mb-4 rounded-4 shadow">
    <div class="row align-items-center">
      <div class="col-md-6">
        <h1 class="display-5 fw-bold mb-3">学生信息查看</h1>
        <p class="lead mb-0">查看学生信息</p>
      </div>
      <div class="col-md-6 text-md-end">
        <div class="d-flex flex-column flex-md-row justify-content-md-end gap-3">
          <div class="position-relative flex-grow-1">
            <form th:action="@{/students}" method="get">
              <input type="text" class="form-control form-control-lg ps-5"
                     name="keyword" th:value="${keyword}"
                     placeholder="搜索学生...">
              <i class="fas fa-search position-absolute top-50 start-0 translate-middle-y ms-3 text-muted"></i>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- 学生列表卡片 -->
  <div class="card border-0 shadow rounded-4 overflow-hidden">
    <div class="card-header bg-white py-3 border-0">
      <div class="d-flex justify-content-between align-items-center">
        <h5 class="card-title mb-0 fw-bold">
          <i class="fas fa-list me-2 text-primary"></i>学生列表
        </h5>
        <div class="text-muted" th:text="'共 ' + ${#lists.size(students)} + ' 名学生'"></div>
      </div>
    </div>
    <div class="card-body p-0">
      <div class="table-responsive">
        <table class="table table-hover align-middle mb-0">
          <thead class="table-light">
          <tr>
            <th class="py-3">#</th>
            <th class="py-3">学生信息</th>
            <th class="py-3">联系方式</th>
            <th class="py-3">院系</th>
            <th class="py-3">年级</th>
          </tr>
          </thead>
          <tbody>
          <tr th:each="student, stat : ${students}" class="animate__animated animate__fadeIn">
            <td class="fw-bold" th:text="${stat.count}"></td>
            <td>
              <div class="d-flex align-items-center">
                <div class="avatar-sm me-3">
                  <div class="avatar-title bg-light-primary text-primary rounded-circle">
                    <i class="fas fa-user"></i>
                  </div>
                </div>
                <div>
                  <h6 class="mb-0" th:text="${student.name}"></h6>
                  <small class="text-muted" th:text="${student.email}"></small>
                </div>
              </div>
            </td>
            <td th:text="${student.phone}"></td>
            <td>
              <span class="badge bg-light text-dark" th:text="${student.department}"></span>
            </td>
            <td>
              <span class="fw-bold" th:text="${student.year} + '年级'"></span>
            </td>
          </tr>
          </tbody>
        </table>
      </div>

      <!-- 空状态 -->
      <div th:if="${students == null or students.isEmpty()}" class="text-center py-5">
        <div class="py-5">
          <img src="https://img.icons8.com/ios/100/cccccc/nothing-found.png" width="80" height="80">
          <h5 class="mt-3">没有找到学生信息</h5>
          <p class="text-muted mb-4">尝试添加新学生或修改搜索条件</p>
        </div>
      </div>
    </div>
  </div>
</div>

<footer class="bg-light py-4 mt-5">
  <div class="container text-center">
    <p class="mb-0">© 2023 学生信息管理系统 | 学生列表</p>
  </div>
</footer>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>